<?php

namespace postController;

require_once 'model/PrintPictures.php';
require_once 'model/Uploadpic.php';
require_once 'view/LogInPage.php';
require_once 'model/LogInModel.php';
require_once 'model/DeleteModel.php';
require_once 'model/EditComments.php';

class PostController{
	private $uploadPic;
	private $printPic;
	private $createComment;
	private $viewlogInPage;
	private $deleteModel;
	private $editComments;
	
	public function __construct(){
		$this->uploadPic = new \uploadPic\UploadPic();
		$this->printPic = new \printPictures\PrintPictures();
		$this->createComment = new \createComments\CreateComments();
		$this->viewlogInPage = new \logInPage\LogInPage();
		$this->model = new \logInModel\LogInModel();
		$this->deleteModel = new \deleteModel\DeleteModel();
		$this->editComments = new \editComments\EditComments();
	}
	
	//@return string (table/pics and comments)
	public function printControl(){
		if($this->model->checkIfLoggedIn()){
			return $table = $this->printPic->postPictures();
		}
		 return $table = "";
	}
	
	//uploads current pic in model
	public function postControl(){
		$this->uploadPic->uploadCurrentPic();
	}
	
	//gets everything to create commens in model
	public function createComments(){
		$pictureId = $this->viewlogInPage->getbuttonValue();
		$user = $this->model->getUsername();
		$comments = $this->viewlogInPage->getComments();
		$this->createComment->saveComments($pictureId, $user, $comments);
	}
	
	//gets everything to delete comment in model
	public function deleteComments(){
		$unique= $this->viewlogInPage->getUnique();
		$this->deleteModel->commentDelete($unique);
	}
	
	//gets everything to edit comment in model
	public function editComment(){
		$newComment = $this->viewlogInPage->getnewComment();
		$editId = $this->viewlogInPage->getEditId();
		$this->editComments->fixComment($editId, $newComment);
	}
}






